/*
   OpenZone2, Everquest 2 data editor
   Copyright (C) 2008  Andrew Fenn
    
	OpenZone2 is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   OpenZone2 is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with OpenZone2.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main(int argc, char** argv)
{
	char buffer[4];
	int total = 0;
	char name[1000] = {0};
	fstream binary_file("test.sp",ios::binary|ios::in);
	binary_file.seekp(19);
	binary_file.read(buffer,4);
	memcpy(&total, buffer, 4);
	
	vector<string> textures;
	
	int totalbytes = 0;
	char temp[1] = {0};
	for (int i=0; i < total; i++) {
		// get the number of bytes we need to read
		binary_file.read(buffer, 2);
		memcpy(&totalbytes, buffer, 1);
		
		for (int i2=0; i2 < totalbytes; i2++) {
			binary_file.read(temp,1);
			//memcpy(&temp, buffer, 2);
			name[i2] = temp[0];
		}
		textures.push_back(string(name));
	}
	binary_file.close();

	for(int i = 0; i < total; i++) {
		cout << textures[i] << endl;
	}
	return 0;
}
